﻿Public Class Form1

    Private Sub ProductsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ProductsBindingNavigatorSaveItem.Click
        Me.Validate()
        Me.ProductsBindingSource.EndEdit()
        Me.TableAdapterManager.UpdateAll(Me.NorthwindDataSet)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'NorthwindDataSet.Categories' table. You can move, or remove it, as needed.
        Me.CategoriesTableAdapter.Fill(Me.NorthwindDataSet.Categories)
        'TODO: This line of code loads data into the 'NorthwindDataSet.Products' table. You can move, or remove it, as needed.
        Me.ProductsTableAdapter.Fill(Me.NorthwindDataSet.Products)

        TextBox1.Text = My.Settings.test


    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Me.ProductsTableAdapter.FillByProductName(Me.NorthwindDataSet.Products, "%" & TextBox1.Text & "%")

    End Sub

    Private Sub TextBox1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
        Me.ProductsTableAdapter.FillByProductName(Me.NorthwindDataSet.Products, "%" & TextBox1.Text & "%")
    End Sub

    Private Sub ComboBox1_SelectedValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedValueChanged
        Dim i As Integer = ComboBox1.SelectedValue
        Me.ProductsTableAdapter.FillByCategoryId(Me.NorthwindDataSet.Products, i)

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.ProductsTableAdapter.Fill(Me.NorthwindDataSet.Products)
    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged
        Dim ta As NorthwindDataSetTableAdapters.CategoryNamesTableAdapter = New NorthwindDataSetTableAdapters.CategoryNamesTableAdapter
        Dim dt As NorthwindDataSet.CategoryNamesDataTable = New NorthwindDataSet.CategoryNamesDataTable
        ta.Fill(dt)
        ComboBox2.DataSource = dt
        ComboBox2.DisplayMember = "CategoryName"
        ComboBox2.ValueMember = "CategoryId"


    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        My.Settings.test = TextBox1.Text
    End Sub
End Class